﻿@model PagedList.IPagedList<HdipCricketClub.Models.Fixture>

@{
    ViewBag.Title = "Fixtures:";
}

<h2>@ViewBag.Title</h2>

<p>
    @Html.ActionLink("Add a fixture", "Create")
</p>

@using (Html.BeginForm())
{
    <p>
    Find by Team: @Html.TextBox("searchString")
    <input type="submit" value="Search" />
    </p>
}
<table>
    <tr>
        <th>
            Team:
        </th>
        <th>
            Opponent:
        </th>
        <th>
            Type:
       </th>
        <th>
            Home:
        </th>
        <th>
            Date:
        </th>
        <th>
            Start Time:
        </th>
        <th>
            No Of Players:
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Team.name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Opponent.club_name) @Html.DisplayFor(modelItem => item.Opponent.team_name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.type)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.home)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.date)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.start_time)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.no_of_players)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id = item.fixture_id }) |
            @Html.ActionLink("Details", "Details", new { id = item.fixture_id }) |
            @Html.ActionLink("Delete", "Delete", new { id = item.fixture_id })
        </td>
    </tr>
}

</table>
<br />
<div>
    Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    of @Model.PageCount

    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("<<", "Index", new { page = 1 })
        @Html.Raw(" ");
        @Html.ActionLink("< Prev", "Index", new { page = Model.PageNumber - 1 })
    }
    else
    {
        @:<<
        @Html.Raw(" ");
        @:< Prev              
    }

    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Next >", "Index", new { page = Model.PageNumber + 1 })
        @Html.Raw(" ");
        @Html.ActionLink(">>", "Index", new { page = Model.PageCount})
    }
    else
    {
        @:Next >
        @Html.Raw(" ");
        @:>>              
    }
</div>
<br />
<div>
    @Html.ActionLink("Return to Admin Page", "Index", "Admin")  |
    @Html.ActionLink("Return to Home Page", "Index", "Home")
</div>